<?php
require 'spl.php';

function valid($p_1, $p_2) {
    //初始化

    $Parameters = new \liyuze\Parameters\Parameters();
    //配置参数和验证规则
    $Parameters->config([
        'p_1' => [$p_1, 'url'],
        'p_2' => [$p_2, ['url', 'patternPart' => [\liyuze\Validators\UrlValidator::URL_PROTOCOLS,'?'
            ,\liyuze\Validators\UrlValidator::URL_IP
            ,\liyuze\Validators\UrlValidator::URL_ADDRESS]] ],
    ], true);

    //验证
    $Parameters->validate();

    return $Parameters->getErrors();
}

function test_pass()
{
    $p_1 = 'http://www.baidu.com/a/b/a.php?a=1&b=3#d3';
    $p_2 = 'www.baidu.com';
    $r = valid($p_1, $p_2);
    return json_encode($r, 256);
}


function test_error()
{
    $p_1 = 'www.baidu.com';
    $p_2 = 'http://127.0.0.12/a/b/c';
    $r = valid($p_1, $p_2);
    return json_encode($r, 256);
}

var_dump(
    test_pass(),
    test_error()
);

